<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>操作记录</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />
    <style>
        .operate-log {
            padding: 10px;
        }
    </style>

</head>

<body>
    <div class="operate-log">
        <section class="aui-grid">
            <div class="aui-row">
                <div class="aui-col-xs-6 " style="padding:0;border-bottom:1px solid #ccc;height:40px;line-height:40px">
                    日期
                </div>
                <div class="aui-col-xs-6 " style="padding:0;border-bottom:1px solid #ccc;height:40px;line-height:40px">
                    内容
                </div>
            </div>
            <div style="text-align:center;margin:0.625rem;display:none;background:#fff;padding:1.25rem;" id="default-1">
              <img src="./img/muyou.png" style="display:inline;">
                <p><span style="font-size:1.25rem;">亲,</span>&nbsp;&nbsp;&nbsp;&nbsp;您当前木有对应的试用品</p>
            </div>
            <div id="list">

            </div>
        </section>
    </div>

</body>
<script type="text/template" id="template">
    {{~it:value:index}}
    <div class="aui-row" style="border-bottom:1px solid #ccc;">
        <div class="aui-col-xs-6 " >
            {{= value.inputtime}}
        </div>
        <div class="aui-col-xs-6 " >
            {{= value.cause}}
        </div>
    </div>
    {{~}}
</script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="./conf/config.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>

<script type="text/javascript">
    apiready = function() {
        fnGetData();
         initRefresh();
    };
    //http://test.renqishike.com/index.php?m=api&c=appnew&a=view_log
    function fnGetData() {
        var userInfo = $api.getStorage('userInfo');
        //获取数据app中存入的数据然后分配到模板中；
        var random = userInfo.random;
        var userid = userInfo.userid;
        var orderId = api.pageParam.orderId;


        api.ajax({
            url: SITE_URL + 'index.php?m=api&c=appnew&a=view_log',
            method: 'POST',
            data: {
                values: {
                    "userid": userid,
                    "random": random,
                    "orderid": orderId,
                }
            }
        }, function(ret, err) {
            //alert(JSON.stringify(ret));
            switch (ret.status) {
              case 0:
                  alert(ret.msg);
                  api.refreshHeaderLoadDone(); //下拉刷新隐藏
                  break;
                case 1:
                      fnUpData(ret);
                    api.refreshHeaderLoadDone(); //下拉刷新隐藏
                    break;
                case 2:
                    alert(ret.msg);
                    api.openWin({
                        name: 'login',
                        url: './login.html',
                        pageParam: {
                            name: 'test'
                        }
                    });

                    //然后关闭当前网页，跳转到另一个网页；
                    break;
                case 5:
                    fnUpdateListDefault();
                    api.refreshHeaderLoadDone(); //下拉刷新隐藏
                    break;
            }
            // if (ret.status == 1) {
            //     fnUpData(ret);
            // } else {
            //     alert(ret.msg);
            // }
        });
    }

    function fnUpData(ret) {
        var list = $api.byId('list'); //获取节点
        //var str={"array":["banana","apple","orange"]};
        // 1. 编译模板函数
        var tempFn = doT.template($api.byId('template').innerHTML); //找到模板多次使用
        // 2. 多次使用模板函数
        var resultText = tempFn(ret.data);
        $api.html(list, "");
        $api.append(list, resultText);
    }
    function initRefresh() {
        api.setRefreshHeaderInfo({
            visible: true,
            loadingImg: 'widget://image/refresh.png',
            bgColor: '#ccc',
            textColor: '#fff',
            textDown: '下拉刷新...',
            textUp: '松开刷新...',
            showTime: true
        }, function(ret, err) {
            //fnGetGoodsList();
          fnGetData();
        });
    }
    function fnUpdateListDefault() {
        $("#default-1").show();
    }
</script>

</html>
